<template>
  <div>
    <div class="wrap">
      <div class="all">
        <div class="head">工资管理后台登录</div>
        <div class="wrap-content">
          <div class="content-img">
            <img src="images/a.png" alt width="420px" height="300px">
          </div>
          <div class="content-log">
            <div class="yonghu">
              <img src="images/yhm.png" alt width="30px" height="30px"
                style="margin: 10px 10px;"
              >
              <input
                type="text"
                placeholder="用户名"
                class="ip1"
                v-model="name"
                autocomplete="off"
                maxlength="15"
              >
            </div>
            <div class="mima">
              <img src="images/mm.png" alt width="30px" height="30px"
                style="margin: 10px 10px;"
              >
              <input
                type="password"
                @keyup.enter="handleLogin"
                placeholder="密码"
                class="ip2"
                v-model="passwords"
              >
            </div>
            <div class="denglu" @click="handleLogin">
              <span class="zi">登录</span>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      ts: this.newStore(),
      name: '',
      passwords: '',
    };
  },
  methods: {
    handleLogin() {
      if (this.name == '') {
        this.$message({
          type: 'error',
          message: '请输入用户名',
        });
        return;
      }
      if (this.passwords == '') {
        this.$message({
          type: 'error',
          message: '请输入密码',
        });
        return;
      }

      const req = {
        handle: 'E299744D88ADCDF5C56442DDF419DB4E33B34DAB6D91425D',
        id: this.name,
        passwords: this.passwords,
      };
      this.spost(this.ts, '/mainservlet', req)
        .then((ts) => {
          if (ts.d.sflag == 'success') {
            localStorage.setItem('token', ts.d.token);
            localStorage.setItem('username', ts.d.data.operation3[0].hash.username);
            this.$root.reload = false;


            this.$nextTick(() => {
              this.$root.reload = true;
            });
            this.$router.push('/glmanager');
          }
        })
        .catch((d) => {
          console.log(d);
        });
    },
  },
};
</script>

<style>
.wrap {
  background-image: url(/images/beijing.jpg);
  width: 100%;
  height: 100vh;
  background-repeat: no-repeat;
  background-size: cover;
  overflow: hidden;
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  bottom: 0;
}
.all {
  /* width: 100%;
  height: 580px; */
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  bottom: 0;
  margin: auto;
}
.wrap-head {
  width: 100%;
  height: 50px;
  position: absolute;
  /* margin: 80px 0px; */
  text-align: center;
}
.head {
  margin-top: 60px;
  font-size: 27px;
  color: #ffffff;
  font-weight: 600;
  text-align: center;
  min-width: 800px;
}
.head-ti {
  margin-top: 10px;
  font-size: 11px;
  color: #ffffff;
  text-align: center;
  min-width: 800px;
}
.wrap-content {
  background-color: #ffffff;
  width: 60%;
  height: 400px;
  margin: 50px auto;
  display: flex;
  min-width: 800px;
  text-align: center;
}
.content-img {
  margin: 55px 20px;
  width: 45%;
}
.content-log {
  width: 50%;
}
.yonghu {
  width: 80%;
  height: 50px;
  background-color: #eef6fd;
  border-bottom: 2px solid #d6e7fa;
  margin-left: 20px;
  margin-top: 100px;
}
.mima {
  width: 80%;
  height: 50px;
  background-color: #eef6fd;
  border-bottom: 2px solid #d6e7fa;
  margin-top: 30px;
  margin-left: 20px;
}
.ip1 {
  display: inline-block;
  width: 80%;
  height: 20px;
  font-size: 15px;
  background-color: #eef6fd;
}
.ip2 {
  display: inline-block;
  width: 80%;
  height: 20px;
  font-size: 15px;
  background-color: #eef6fd;
}
.denglu {
  width: 80%;
  height: 50px;
  margin-top: 30px;
  margin-left: 20px;
  background-color: #1592ef;
  text-align: center;
  line-height: 50px;
  border-radius: 10px;
  text-shadow: 2px 2px 1px rgba(0, 0, 0, 0.2);
  box-shadow: 2px 2px 1px rgba(0, 0, 0, 0.2);
  cursor: pointer;
}
.zi {
  font-size: 20px;
  color: #ffffff;
  cursor: pointer;
}
</style>
